Socket
Socket
Sign inDemoInstall

html-parse-stringify2

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-parse-stringify2

Parses well-formed HTML (meaning all tags closed) into an AST and back. quickly.


Version published
Weekly downloads
125K
increased by6.86%
Maintainers
1
Weekly downloads
 
Created

What is html-parse-stringify2?

The html-parse-stringify2 npm package is a utility for parsing HTML strings into a JSON format and vice versa. It is useful for manipulating and analyzing HTML content programmatically.

What are html-parse-stringify2's main functionalities?

Parsing HTML to JSON

This feature allows you to convert an HTML string into a JSON object. The JSON object represents the structure of the HTML content, making it easier to manipulate and analyze.

const parse = require('html-parse-stringify2').parse;
const html = '<div><p>Hello, World!</p></div>';
const json = parse(html);
console.log(JSON.stringify(json, null, 2));

Stringifying JSON to HTML

This feature allows you to convert a JSON object back into an HTML string. This is useful for generating HTML content programmatically from a structured data format.

const stringify = require('html-parse-stringify2').stringify;
const json = [{
  type: 'tag',
  name: 'div',
  children: [{
    type: 'tag',
    name: 'p',
    children: [{
      type: 'text',
      content: 'Hello, World!'
    }]
  }]
}];
const html = stringify(json);
console.log(html);

Other packages similar to html-parse-stringify2

Keywords

FAQs

Package last updated on 28 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc